<template>
	<div id="noteTree">
		<div class="noteTree_top">
			<i class="el-icon-arrow-left" @click="goBack"></i>
			<button class="btn" @click="keepAll" :id="thisid">保存</button>
		</div>
		<div class="noteTree_top_bd">
			<el-tree :data="datas" :props="defaultProps" @check-change="handleNodeClick" @node-click="templateClick" ref="tree" show-checkbox  :check-strictly="true"></el-tree>
		</div>
	</div>
</template>

<script>
	import store from '@/vuex/store'
	export default {
		name: 'noteTree',
		data() {
			return {
				datas: '',
				checkedId: '',
				thisid:'',
//				type:'',
				defaultProps: {
					children: 'children',
					label: 'label'
				}
			}
		},
		methods: {
			goBack() {
				history.back(-1)
			},
			handleNodeClick(clickdatas) {
				debugger
				if(clickdatas.fileType == "folder") {
					this.thisid = clickdatas.id;
				} else {
					this.thisid = clickdatas.id;
					
				}
//				if(this.checkedId != ""){
//					if(this.checkedId != data.id){
//						this.$refs.tree.setCheckedKeys([]);
//						this.$refs.tree.setCheckedKeys(data.id);
//						this.checkedId = data.id;
//					}
//				}
//				if(checked === true) {
//	        		this.checkedId = data.id;
//				}
//				 
			},
			keepAll() {
//				debugger
//				let aa = this.thisid;
				this.$confirm('是否确认保存?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let params = {
 						id: this.thisid,
						type: 'folder'
					}
					this.$post("/app/post/AppMyNoteController/queryMoveToFile", params).then((json) => {
						// id: params.id
						if(json.returnCode == 0) {
							this.$message({
								type: 'success',
								message: '移动成功!',
							});
							this.$router.push({
								path:'Notes',
								query:{
									id :params.id,
									
								}
							})
						} else {
							this.$message({
								message: json.returnMessage
							});
						}
 					});

				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消移动'
					})
				})
				}
		},
		created() {
			this.datas = this.$route.query.thisData
		}
	}
</script>

<style>
	#noteTree {
		width: 100%;
		height: 100%;
		font-size: 0.14rem;
	}
	
	.noteTree_top {
		width: 100%;
		height: 0.45rem;
		background-color: lightblue;
	}
	
	.el-icon-arrow-left {
		font-size: 0.3rem;
		margin-top: 0.1rem;
		margin-left: 0.1rem;
	}
	
	.btn {
		width: 0.5rem;
		height: 0.2rem;
		margin-left: 2.6rem;
		background-color: white;
		border: none;
	}
</style>